//
//  NewTableViewCell.m
//  UITableView
//
//  Created by dllo on 16/6/21.
//  Copyright © 2016年 dllo. All rights reserved.
//
#define kWidth self.contentView.frame.size.width
#define kHeight self.contentView.frame.size.height
#import "NewTableViewCell.h"
#import "Contact.h"
@interface NewTableViewCell ()
@property (nonatomic, retain)UILabel *numberLabel;
@property (nonatomic, retain)UILabel *nameLabel;
@property (nonatomic, retain)UIImageView *iamgeView;

@end
@implementation NewTableViewCell
-(void)dealloc{
    [_iamgeView release];
    [_nameLabel release];
    [_numberLabel release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self =[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.iamgeView = [[UIImageView alloc]init];
        [self.contentView addSubview:_iamgeView];
        self.numberLabel = [[UILabel alloc]init];
        [self.contentView addSubview:_numberLabel];
        [_numberLabel release];
        self.nameLabel = [[UILabel alloc]init];
        [self.contentView addSubview:_nameLabel];
        [_nameLabel release];

        
    }
    return self;
}
-(void)layoutSubviews{
    self.iamgeView.frame = CGRectMake(10, 10, kWidth * 0.3, kHeight - 20);
    self.iamgeView.backgroundColor = [UIColor greenColor];
    
    self.nameLabel.frame = CGRectMake(_iamgeView.frame.size.width + 40, 20, kWidth * 0.5, kHeight * 0.2);
    self.nameLabel.backgroundColor = [UIColor brownColor];
    
    self.numberLabel.frame = CGRectMake(_nameLabel.frame.origin.x, kHeight* 0.2 + 40, kWidth * 0.5, kHeight * 0.2);
    self.numberLabel.backgroundColor = [UIColor orangeColor];
}

-(void)setContact:(Contact *)contact{
    if (_contact != contact) {
        [_contact retain];
        _contact = [contact retain];
        
    }
    _iamgeView.image = [UIImage imageNamed:contact.picture];
    _iamgeView.backgroundColor = [UIColor whiteColor];
 
    _nameLabel.text = contact.name;
    _numberLabel.text = contact.number;
    
   
    }











@end
